import { findAll } from "@/api/dept";

export async function dialogsFunc() {

    const { data: deptList = [] } = await findAll()
    const depts = deptList.map(item => {
        return {
            label: item.name,
            value: item.name
        }
    })

    return {
        fields: [
            {
                el: 'str-input',
                label: '姓名',
                value: 'user_name',
                rule: { required: true },
                option: {}
            }, {
                el: 'iv-select',
                label: '性别',
                value: 'sex',
                rule: { required: true },
                option: {
                    selects: [
                        {
                            label: '男',
                            value: '1'
                        },
                        {
                            label: '女',
                            value: '0'
                        }
                    ]
                }
            }, {
                el: 'iv-select',
                label: '角色',
                value: 'type',
                rule: { required: true },
                option: {
                    selects: [
                        {
                            label: '管理员',
                            value: 'admin'
                        },
                        {
                            label: '员工',
                            value: 'employee'
                        }
                    ]
                }
            }, {
                el: 'str-input',
                label: '登录名',
                value: 'login_name',
                rule: { required: true },
                option: {}
            }, {
                el: 'str-input',
                label: '密码',
                value: 'passwd',
                rule: { required: true },
                option: {}
            }, {
                el: 'str-input',
                label: '工号',
                value: 'user_no',
                rule: { required: true },
                option: {}
            }, {
                el: 'str-input',
                label: '邮箱',
                value: 'email',
                option: {}
            }, {
                el: 'iv-select',
                label: '部门',
                value: 'dept_name',
                rule: {},
                option: {
                    selects: depts
                }
            }
        ]
    }
}